<?php
//includierte Dateien
include 'config.php';
include 'function.php';
//includierte Dateien

echo ('<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//DE">
<html>
<head>
<title>Rapidshare Upload Script</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>');
echo ('<body><font color="#4169e1">Ordner</font> werden in <font color="#4169e1">Royalblue</font> angezeigt,<br>Dateien in Black<br>'."\n");
echo ("Dateien die sich im Ordner $path befinden : <br><br>\n");
echo ('<table>'."\n");

if ($handle = opendir("$path")) {
    while (false !== ($file = readdir($handle))) {
        if ($file != "." && $file != "..") {
$full_path = "$path/$file";
if (is_dir($full_path))
{
$size = format_size(dir_size($full_path))." <td>Verzeichnis";
$file_color="#4169e1";

}else
{
$size = format_size(filesize($full_path));
$file_color="#000000";
}
echo ("<tr><td><font color=\"$file_color\">".resize($file)."</font></td>\n");
echo ("<td><a href=\"rar.php?file=$file\"><font color=green>[rar erstellen]</font></a></td>\n");
echo ("<td><a href=\"rar.php?file=$file&amp;pass=1\"><font color=green>[rar mit PW und Size]</font></a></td>\n");
echo ("<td><a href=\"del.php?file=$file\"><font color=red>[l&ouml;schen]</font></a></td>\n");
echo ("<td> $size</td>\n</tr>\n");
        }
    }
    closedir($handle);
}
echo ('</table>'."\n");
echo ("<table><tr><td>File muss im Ordner \"$path\" sein"."\n");
echo ('<form name="form1" method="post" action="">'."\n");
echo ('<textarea name="file" cols="70" rows="6"></textarea> '."\n");
echo ('<br><input type=submit name=Loslos value=Uploaden>'."\n");
echo ("</form>\n");
echo ('<form name="form2" method="post" action="">'."\n");
echo ('<input type=hidden name=copy value=copy>'."\n");
echo ('<br><input type=submit name=Loslos value="Liste zum kopieren">'."\n");
echo ("</form>\n");
echo ('<form name="form3" method="post" action="clear.php">'."\n");
echo ('<input type=hidden name=clear value=clear>'."\n");
echo ('<br><input type=submit name=clear value="Liste der hochgelandenen Rapidshare Dateien entfernen">'."\n");
echo ("</form>\n");
echo ('</td></tr></table>'."\n");
echo ('<table><tr>'."\n");

$host_num = 4; //Unterstützte Antahl von Hostern
for ($i=1; $i<=$host_num; $i++)
{
switch ($i) {
case 1:
	$hoster = 'rapidshare';
	break;
case 2:
	$hoster = 'uploaded';
	break;
case 3:
	$hoster = 'netload';
	break;
case 4:
	$hoster = 'filefactory';
	break;
}
echo ('<td><form method="post" action="">'."\n");
echo ('<input type=submit value="Nur '.$hoster.'" name='.$hoster.'>');
echo ('<input type=hidden name="hoster" value='.$hoster.'>');
echo ('</form></td>'."\n");
}
echo ('<td><form method="post" action="">'."\n");
echo ('<input type=submit value="Datei" name=datei>'."\n");
echo ('<input type=hidden name=hoster value=datei>'."\n");
echo ('</form></td></tr></table><br>');
if (isset($_POST['copy']))
{
if ($handle = opendir("$path")) {
    while (false !== ($file = readdir($handle))) {
        if ($file != "." && $file != "..") {
	if (!is_dir("$path/$file"))
            echo "$file<br>";
        }
    }
    closedir($handle);
}
}
echo ('<br>');
if (isset($_POST['file']))
    {
        $file  = $_POST['file'];
        $teile = explode("\n", $file);
        $anzahl = count($teile);

        for ($i = 0; $i<$anzahl; $i++)
            { 
                if (is_file(trim("$path/$teile[$i]")))
                {
                        $file2 = trim($teile[$i]);
                        echo ("".trim($teile[$i])." Datei gefunden<br>");
				
			if($rapidsharemethode != "")
			{
				$rapidset = "-s rapidshare.com --$rapidsharemethode ";
				if($rapidshareuser != "" && $rapidsharepassword != "")
				{
				$rapidset .= "-u '$rapidshareuser' -p '$rapidsharepassword' ";
				}
			}
			if($uploadedmethode != "")
			{
				$uploadedset = "-s uploaded.to --$uploadedmethode ";
				if($uploadeduser != "" && $uploadedpassword != "")
				{
				$uploadedset .= "-u '$uploadeduser' -p '$uploadedpassword' ";
				}
			}
			if($netloadmethode != "")
			{
				$netloadset = "-s netload.in --$netloadmethode ";
				if($netloaduser != "" && $netloadpassword != "")
				{
				$netloadset .= "-u '$netloaduser' -p '$netloadpassword' ";
				}
			}
			if($filefactorymethode != "")
			{
				$filefactoryset = "-s filefactory.com --$filefactorymethode ";
				if($filefactoryuser != "" && $filefactorypassword != "")
				{
				$filefactoryset .= "-u '$filefactoryuser' -p '$filefactorypassword' ";
				}
			}
			exec("bash ./nixshare.sh ".$rapidset.$uploadedset.$netloadset.$filefactoryset." $path/$file2");
                        echo ("Upload fertig!<br>");
			$fp=fopen("uploadsys.log","r");
                            if ($fp)
                                {
                                    while(!feof($fp))
                                        {
                                            $text = fgets($fp);
                                            echo (nl2br($text));
                                        }
                                        fclose($fp);
                                }

                        
                }
                else
                {
                    echo ("<br>
                    ".trim($teile[$i])." datei wurde nicht gefunden.<br>");
                }
            }
    }

$datei = "uploadsys.log"; // Name der Datei
$array = file($datei);
$zende = count($array);

if (isset($_POST['hoster']))
for ($i=0; $i<$zende; $i++) 
{
        $durch = $array[$i];
	if ($_POST['hoster'] == 'rapidshare')
	$pos = strpos("$durch", 'Download: http://r');
	elseif ($_POST['hoster'] == 'uploaded')
	$pos = strpos("$durch", 'Download: http://u');
	elseif ($_POST['hoster'] == 'netload')
	$pos = strpos("$durch", 'Download: http://n');
	elseif ($_POST['hoster'] == 'filefactory')
	$pos = strpos("$durch", 'Download: http://www.f');
	else
	{
	$pos = false;
	echo substr("$array[$i]", 10);
	echo "<br>";
	}
	if ($pos === false) {
	
	}
	else
	{
	echo substr("$array[$i]", 10);
	echo "<br>";
	}
}
echo ('</body>');
echo ('</html>');
?>
